<template>
    <div class="left-cpn">
        <ul>
            <li
                v-for="item in list"
                :key="item.id"
                @click="changeLi(item.path)"
                :class="item.path === newPath ? 'changeColor' : ''"
            >
                {{ item.name }}
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list: [
                {
                    id: 1,
                    name: '用户信息管理',
                    path: '/userInfo'
                },
                {
                    id: 2,
                    name: '视频管理',
                    path: '/video'
                },
                {
                    id: 3,
                    name: '数据修改',
                    path: '/datas'
                }
            ],
            newPath: '/userInfo'
        };
    },
    methods: {
        changeLi(val) {
            // console.log(val);
            this.newPath = val;
            this.$router.push(this.newPath);
        }
    },
    mounted() {
        this.changeLi(this.newPath);
    }
};
</script>

<style lang="scss" scoped>
.left-cpn {
    width: 220px;
    height: calc(100vh - 80px);
    background-color: rgb(82, 74, 74);
    text-align: center;
    padding-top: 30px;
    ul {
        li {
            list-style: none;
            margin-top: 20px;
        }
        li:hover {
            cursor: pointer;
            color: #4caf50;
        }
        .changeColor {
            color: #4caf50;
        }
    }
}
</style>
